<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>预备上传</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    	
	<script src="/resources/scripts/clearFile.js" type="text/javascript"></script>
	<script type="text/javascript">
	
	 /*检查图片上传类型*/		
	 function checkImgType(obj){
		  var imgFile = '';	
		  //获取图片的全路径
		  var tag = true;	 	
		  var ImgName = document.getElementById("imgFile").value;
		  if (ImgName.toLowerCase().indexOf("gif")==-1 && ImgName.toLowerCase().indexOf("jpg")==-1 && ImgName.toLowerCase().indexOf("png")==-1 && ImgName.toLowerCase().indexOf("bmp")==-1){ 
		      alert("上传图片的文件类型必须为: *.gif,*.jpg,*.png,*.bmp,请重新选择!")
		      Upload.clear(obj);			      	 
		 	  return false;
		  }
		  else{ 
			 //不知道其他阅览器怎么样 目前仅支持IE 7 8和ff  
			 if (window.navigator.userAgent.indexOf("MSIE") >= 1) {  
		          document.getElementById("form1").target="dialogFrame";
		     }else{
		     	  document.getElementById("form1").target="_self";
		     } 
			document.getElementById("form1").submit();
		  }
	  }	
	  function getImgFullPath(obj) {
		    if (obj) {
		       //ie  
		       if (window.navigator.userAgent.indexOf("MSIE") >= 1) {  
		           obj.select();  
		           return document.selection.createRange().text;  
		       }  
		       //ff
		       else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {  
		           if (obj.files) {  
		               return obj.files.item(0).getAsDataURL();  
		           }  
		           return obj.value;  
		       }         
		       return obj.value;  
		   }  
	  } 
		
	  //初始化提交FORM的TARGET值。   
	  window.attachEvent('onload', function(){   
	 			 if(window.name=""){ //判断窗体的name，防止查询或者翻页操作时弹出新窗口   
	     			 document.getElementById("form1").target = "dialogFrame";   
	  			 }else if(window.name="dialogFrame"){//判断执行查询或翻页操作后，返回当前页面不刷新展现新数据   
	     			 document.getElementById("form1").target = "";   
	            }   
	  }) 
	</script>
	
  </head>  
  <body>
    <form name=form1 id="form1" method=post enctype="multipart/form-data" action="<%=path%>/jadestudio/common.do?pm=imgUpload" target="dialogFrame">
    	<div>
    	<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" >    	   
          <tbody align="center" valign="middle">
           <tr>              
               <td>&nbsp;公共图片上传组件v1.0</td>              
           </tr>  
           <tr>              
               <td>&nbsp;格式必须为<font color='red'>*.gif,*.jpg,*.png,*.bmp</font></td>              
           </tr>
           <tr>              
               <td>&nbsp;不支持chrome<font color='red'>尽量避免使用</font></td>              
           </tr>
           <tr >   
               <td width="80%">            	
		         <input type="file" name="imgFile" id="imgFile" maxlength="160" onchange="checkImgType(this);" width="300px"/>&nbsp;	                     
		       </td>    
           </tr>   
           </tbody>            
    	</table>  
       </div>
    </form>
  </body>
</html>
